﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestModule
{
    /// <summary>
    /// 绘图线单元符号
    /// </summary>
    public class NodeLine : NodeLineSymbol
    {
        /// <summary>
        /// 起点
        /// </summary>
        private Point _beginPoint;
        public Point BeginPoint
        {
            get { return _beginPoint; }
            set { _beginPoint = value; }
        }

        /// <summary>
        /// 尾点
        /// </summary>
        private Point _endPoint;
        public Point EndPoint
        {
            get { return _endPoint; }
            set { _endPoint = value; }
        }

        /// <summary>
        /// 绘制线
        /// </summary>
        public override void Draw(Graphics img)
        {
            if (BNo)
                img.DrawString(this.Index.ToString(), new Font("Verdana", 10), new SolidBrush(Color.Tomato), this.BeginPoint);

            if (BRemark)
                img.DrawString(this.Remark, new Font("Verdana", 10), new SolidBrush(Color.Tomato), new Point() { X= (this.BeginPoint.X + this.EndPoint.X) / 2, Y = (this.BeginPoint.Y + this.EndPoint.Y) / 2});
            
            Pen pen = new Pen(base.PenColor, base.Width);
            if (base.BDirection)
            {
                AdjustableArrowCap lineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(10, 15, true);
                pen.CustomEndCap = lineCap;
            }

            img.DrawLine(pen,this.BeginPoint, this.EndPoint);   
        }
    }
}
